using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public class SolarSystemJump : EveAssociation<SolarSystem, SolarSystem>
    {
        private int fromRegionId;
        private int fromConstellationId;
        private int toConstellationId;
        private int toRegionId;

        private Region fromRegion;
        private Constellation fromConstellation;
        private Constellation toConstellation;
        private Region toRegion;

        public SolarSystem FromSolarSystem
        {
            get { return From; }
        }
        public SolarSystem ToSolarSystem
        {
            get { return To; }
        }
        public Constellation FromConstellation
        {
            get
            {
                if (fromConstellation == null)
                    fromConstellation = new Constellation(db, fromConstellationId);
                return fromConstellation;
            }
        }
        public Constellation ToConstellation
        {
            get
            {
                if (toConstellation == null)
                    toConstellation = new Constellation(db, toConstellationId);
                return toConstellation;
            }
        }
        public Region FromRegion
        {
            get
            {
                if (fromRegion == null)
                    fromRegion = new Region(db, fromRegionId);
                return fromRegion;
            }
        }
        public Region ToRegion
        {
            get
            {
                if (toRegion == null)
                    toRegion = new Region(db, toRegionId);
                return toRegion;
            }
        }

        internal SolarSystemJump(DbDataRow dr)
            : base(dr.Database, new SolarSystem(dr.Database, dr["fromSolarSystemID"]), new SolarSystem(dr.Database, dr["toSolarSystemID"]))
        {
            Fill(dr);
        }

        private void Fill(DbDataRow dr)
        {
            fromRegionId = dr["fromRegionID"];
            fromConstellationId = dr["fromConstellationID"];
            toConstellationId = dr["toConstellationID"];
            toRegionId = dr["toRegionID"];
        }
    }
}
